<script>
export default {
    props: {
        title: {
            type: String,
            default: ''
        },
        show: {
            type: Boolean,
            default: false
        },
    },
    data() {
        return {
            parentShow: false,
            currentShow: false
        }
    },
    watch: {
        show(newVal) {
            if (newVal) {
                this.parentShow = true
                setTimeout(() => {
                    this.currentShow = true
                }, 100)
            } else {
                this.currentShow = false
                setTimeout(() => {
                    this.parentShow = false
                }, 250)
            }
        }
    },
    methods: {
        close() {
            this.currentShow = false
            setTimeout(() => {
                this.$emit('update:show', false)
            }, 300)
        }
    }
}
</script>
<template>
    <div v-show="parentShow" class="modal-c">
        <div class="mask" :class="{ 'mask-show': currentShow }">

        </div>
        <div class="content" :class="{ 'content-show': currentShow }">

            <div class="w-full">
                <div class="between p-30">
                    <div class="fz28 font-bold ml-10">{{ title }}</div>
                    <div class="close" @click="close">
                        <image src="/static/icon/close.png" mode="widthFix" style="width: 30rpx;"></image>
                    </div>
                </div>

                <slot></slot>
            </div>
            <!-- <div @click="close()">关闭</div> -->
        </div>
    </div>
</template>


<style lang="less">
.modal-c {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: all 0.3s;
}

.mask-show {
    opacity: 1;
}

.content {
    position: fixed;
    bottom: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    background-color: #fff;
    width: 100%;
    transform: translate3d(0, 100%, 0);
    transition: all 0.3s;
}

.content-show {
    transform: translate3d(0, 0, 0);
}
</style>